// 监听图表周期变化
function detectTimeframe() {
  const buttons = document.querySelectorAll('[data-name="interval-button"]');
  if (buttons.length > 0) {
    const activeBtn = Array.from(buttons).find(btn => 
      btn.getAttribute('data-active') === 'true'
    );
    return activeBtn ? activeBtn.textContent.trim() : 'UNKNOWN';
  }
  return 'UNKNOWN';
}

// 周期变化时发送消息给插件
setInterval(() => {
  const currentTF = detectTimeframe();
  chrome.runtime.sendMessage({
    type: 'TIMEFRAME_UPDATE',
    timeframe: currentTF
  });
}, 1000); 